package Recursive_search_backtracking_algorithm.Topic1_recursive_algorithm.Topic1_recursive_algorithm;

import java.util.List;

public class hanota_lcci {
    //面试题08.06.汉诺塔问题
    //https://leetcode.cn/problems/hanota-lcci/
    public void hanota(List<Integer> A, List<Integer> B, List<Integer> C) {
        dfs( A, B, C, A.size());
    }
    public void dfs (List<Integer> A, List<Integer> B, List<Integer> C,int n){
        if(n==1){
            C.add(A.remove(A.size()-1));
            return;
        }
        dfs(A,C,B,n-1);
        C.add(A.remove(A.size()-1));
        dfs(B,A,C,n-1);
    }
}
